package com.editso.haier.bean;

import com.editso.haier.util.Pair;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * {
 *     "name": "测试",
 *     "price": 100,
 *     "topic": "",
 *     "tags": [],
 *     "description": "",
 *     "options": [
 *          {
 *              key: "",
 *              items: [<options>]
 *          }
 *     ],
 *     "sizeImages": [
 *         {
 *             "path": "",
 *             "fileName": ""
 *         },
 *     ],
 *     "appearanceImages": [],
 *     "introduceImages": [
 *         {
 *             "path": "",
 *             "fileName": ""
 *         }
 *     ],
 *     "helpFile": []
 * }
 * */

@Getter
@Setter
@ToString
public class CommodityBean {
    private String name;
    private String price;
    private Integer topic;
    private List<String> tags;
    private String description;
    private List<Map<String, Object>> options;
    private List<Map<String, String>> sizeImages;
    private List<Map<String, String>> appearanceImages;
    private List<Map<String, String>> introduceImages;
    private List<Map<String, String>> helpFile;

    public enum AssetsOther{
        SIZE("image/*"),
        APPEARANCE("image/*"),
        INTRODUCE("image/*"),
        HELP("file");
        private final String contentType;
        AssetsOther(String contentType) {
            this.contentType = contentType;
        }
        public String getContentType() {
            return contentType;
        }
    }

    public List<Pair<AssetsOther, List<Map<String, String>>>> assetsPairs(){
        return Arrays.asList(
                Pair.from(AssetsOther.APPEARANCE, appearanceImages),
                Pair.from(AssetsOther.SIZE, sizeImages),
                Pair.from(AssetsOther.INTRODUCE, introduceImages),
                Pair.from(AssetsOther.HELP, helpFile));
    }
}
